﻿using Moq;
using System.IO;
using System.Threading.Tasks;
using TabbedTemplate.Services;

namespace UnitTest.Helpers
{
    public class FavoriteStorageHelper
    {
        /// <summary>
        /// 删除数据库文件
        /// </summary>
        public static void RemoveDatabaseFile() =>
            File.Delete(FavoriteStorage.StoreDbPath);

        /// <summary>
        /// 获得已初始化的诗词存储
        /// </summary>
        public static async Task<FavoriteStorage> GetInitializedFavoriteStorage()
        {
            var _favoriteStorage =
                new FavoriteStorage(new Mock<IPreferenceStorage>().Object);
            if (!_favoriteStorage.Initialized())
            {
                await _favoriteStorage.InitializeAsync();
            }
            return _favoriteStorage;
        }
    }
}
